home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / SCROLL.ASM < prev    next >
Assembly Source File  |  1993-05-05  |  11KB  |  350 lines

  1. ;========================================================
  2. ; SCROLL -- By Eric Tauck
  3. ;
  4. ; This is a TSR to pause the screen and wait for a key-
  5. ; stroke after a certain number of consecutive lines have
  6. ; been displayed.  SCROLL is only enabled when scroll
  7. ; lock is activated.  The scroll lock key may be pressed
  8. ; to unpause the screen and disable SCROLL.
  9. ;
  10. ; This program works by counting the number of linefeeds
  11. ; displayed with the teletype function of INT 10.  SCROLL
  12. ; will not work with any device drivers or programs that
  13. ; bypass INT 10, like ANSI.SYS.
  14. ;
  15. ; Usage: SCROLL [lines]
  16. ;
  17. ; The default number lines is 24.
  18. ;
  19. ; This program is written for WASM and uses several of
  20. ; the WASM library files.
  21.  
  22.         jmp     install
  23.  
  24. BEGIN_RESIDENT
  25.  
  26. NEWLOC  EQU     80H
  27. RELOC   EQU     $ - NEWLOC
  28.  
  29. ;========================================
  30. ; Resident data.
  31.  
  32. page    DB      ?               ;paused page number
  33. cols    DB      ?               ;paused columns
  34.  
  35. lines   DW      24              ;lines to show before pause
  36. scroll  DW      ?               ;current lines shown
  37.  
  38. old10   LABEL   DWORD           ;original interrupt 10H
  39.         DW      ?, ?
  40.  
  41. old16   LABEL   DWORD           ;original interrupt 16H
  42.         DW      ?, ?
  43.  
  44. prompt  DB      10,13,'Press any key to continue...',0
  45.  
  46. ;========================================
  47. ; Reset the scroll count.
  48.  
  49. Reset   PROC    NEAR
  50.         seg     cs
  51.         push    lines - RELOC
  52.         seg     cs
  53.         pop     scroll - RELOC
  54.         ret
  55.         ENDP
  56.  
  57. ;========================================
  58. ; Return scroll lock state.
  59. ;
  60. ; Out: ZF= set if not locked.
  61.  
  62. Lock    PROC    NEAR
  63.         push    ax
  64.         mov     ah, 2           ;get shift status
  65.         pushf
  66.         seg     cs
  67.         call    old16 - RELOC   ;execute
  68.         test    al, 10H         ;set ZF
  69.         pop     ax
  70.         ret
  71.         ENDP
  72.  
  73. ;========================================
  74. ; Wait for key or scroll off. Assume
  75. ; DS = CS.
  76.  
  77. Wait    PROC    NEAR
  78. wait1   call    Lock            ;check scroll lock
  79.         jz      wait2           ;exit if cleared
  80.         mov     ah, 1           ;keyboard status
  81.         pushf
  82.         call    old16 - RELOC   ;execute
  83.         jz      wait1
  84.         sub     ah, ah          ;read keystroke
  85.         pushf
  86.         call    old16 - RELOC   ;execute
  87. wait2   ret
  88.         ENDP
  89.  
  90. ;========================================
  91. ; Type a string.  Assume DS = CS.
  92. ;
  93. ; In: SI= string.
  94.  
  95. Message PROC    NEAR
  96.         jmps    type2
  97.  
  98. type1   push    si
  99.         mov     ah, 0EH         ;TTY function
  100.         mov     bl, 7           ;color (graphics mode only)
  101.         pushf
  102.         call    old10 - RELOC   ;execute
  103.         pop     si
  104.  
  105. type2   cld
  106.         lodsb                   ;load next byte
  107.         or      al, al          ;check if end of string
  108.         jnz     type1           ;loop back if not
  109.  
  110.         ret
  111.         ENDP
  112.  
  113. ;========================================
  114. ; Home cursor and clear the line.  Assume
  115. ; DS = CS.
  116.  
  117. Clear   PROC    NEAR
  118.  
  119. ;--- goto start of line
  120.  
  121.         mov     ax, 0E0DH               ;TTY carriage return
  122.         mov     bl, 7                   ;color (graphics mode only)
  123.         pushf
  124.         call    old10 - RELOC           ;execute
  125.  
  126. ;--- clear the characters
  127.  
  128.         mov     ax, 0920H               ;write spaces
  129.         mov     bl, 7                   ;color (graphics mode only)
  130.         mov     bh, page - RELOC        ;page
  131.         mov     cl, cols - RELOC        ;columns
  132.         sub     ch, ch
  133.         pushf
  134.         call    old10 - RELOC           ;execute
  135.         ret
  136.         ENDP
  137.  
  138. ;========================================
  139. ; Pause the display.
  140.  
  141. Pause   PROC    NEAR
  142.         push    ax
  143.         push    bx
  144.         push    cx
  145.         push    dx
  146.         push    di
  147.         push    si
  148.         push    bp
  149.         push    ds
  150.  
  151.         push    cs                              ;load data segment
  152.         pop     ds                              ;
  153.  
  154.         mov     ah, 0FH                         ;get info function
  155.         pushf
  156.         call    old10 - RELOC                   ;execute
  157.         mov     cols - RELOC, ah                ;save columns
  158.         mov     page - RELOC, bh                ;save active page
  159.  
  160.         mov     si, OFFSET prompt - RELOC       ;pause prompt
  161.         call    Message                         ;display
  162.         call    Wait                            ;wait for keystroke
  163.         call    Clear                           ;clear this line
  164.  
  165.         pop     ds
  166.         pop     bp
  167.         pop     si
  168.         pop     di
  169.         pop     dx
  170.         pop     cx
  171.         pop     bx
  172.         pop     ax
  173.         ret
  174.         ENDP
  175.  
  176. ;========================================
  177. ; Interrupt 16H handler.  Reloads scroll
  178. ; count if input function.
  179.  
  180. New16   PROC    FAR
  181.         or      ah, ah                  ;check if standard input function
  182.         jz      new161
  183.         cmp     ah, 10H                 ;check if extended input function
  184.         jne     new162
  185. new161  call    Reset                   ;reset scroll count
  186. new162  seg     cs
  187.         jmp     old16 - RELOC
  188.         ENDP
  189.  
  190. ;========================================
  191. ; Interrupt 10H handler.
  192.  
  193. New10   PROC    FAR
  194.  
  195. ;--- check video function
  196.  
  197.         cmp     ah, 05H         ;set video page
  198.         je      new103
  199.         cmp     ah, 07H         ;scroll down
  200.         je      new103
  201.         cmp     ah, 06H         ;scroll up
  202.         jne     new101
  203.         cmp     al, 1           ;check if not one line
  204.         jne     new103
  205. new101  cmp     ah, 0EH         ;teletype character
  206.         jne     new104
  207.         cmp     al, 10          ;check if linefeed
  208.         jne     new104
  209.  
  210. ;--- teletype linefeed
  211.  
  212.         seg     cs
  213.         cmp     scroll - RELOC, 0       ;check if count expired
  214.         je      new102
  215.         seg     cs
  216.         dec     scroll - RELOC          ;decrement count
  217. new102  call    Lock                    ;check if scroll lock
  218.         jz      new104
  219.         seg     cs
  220.         cmp     scroll - RELOC, 0       ;check if count expired
  221.         jnz     new104
  222.  
  223.         call    Pause                   ;pause
  224.         call    Reset                   ;reset count
  225.         iret
  226.  
  227. ;--- no pause
  228.  
  229. new103  call    Reset                   ;reset count
  230. new104  seg     cs
  231.         jmp     old10 - RELOC
  232.         ENDP
  233.  
  234. END_RESIDENT
  235.  
  236. ;========================================
  237. ; Installation.
  238.  
  239. ;--- installation entry point
  240.  
  241. install INCLUDE 'library\case1.asm'
  242.         INCLUDE 'library\convert.asm'
  243.         INCLUDE 'library\parms.asm'
  244.         INCLUDE 'library\message1.asm'
  245.  
  246. ;--- banner
  247.  
  248.         mov     ax, OFFSET banner
  249.         call    MesPutL                 ;display banner
  250.  
  251. ;--- read parameter
  252.  
  253.         call    ParGet                  ;get first parameter
  254.         jc      skip
  255.         mov     si, ax
  256.  
  257.         mov     cx, OFFSET help         ;response if '?'
  258.         cmp     BYTE [si], '?'          ;check if question mark
  259.         je      termx
  260.         mov     ax, si
  261.         mov     cx, 10
  262.         call    Str2Num                 ;convert to number
  263.         mov     cx, OFFSET error        ;response if error
  264.         jc      termx                   ;jump if error
  265.         or      dx, dx                  ;check if 32 bit number
  266.         jnz     termx                   ;exit if so
  267.  
  268.         mov     lines, ax               ;save number of lines
  269.         jmps    skip
  270.  
  271. termx   jmps    term                    ;terminate relay
  272.  
  273. ;--- display scroll lines
  274.  
  275. skip    mov     ax, OFFSET status
  276.         call    MesPut                  ;display prompt
  277.         mov     ax, lines
  278.         sub     dx, dx
  279.         mov     cx, 10
  280.         mov     bx, OFFSET buffer
  281.         call    Num2Str                 ;convert lines to string
  282.         mov     ax, OFFSET buffer
  283.         call    MesPutL                 ;display lines
  284.  
  285. ;--- install
  286.  
  287.         mov     ax, lines                       ;copy scroll
  288.         mov     scroll, ax                      ;
  289.  
  290.         push    es
  291.         mov     ax, 3510H                       ;get interrupt 10H function
  292.         int     21H                             ;execute
  293.         mov     WORD old10, bx                  ;save offset
  294.         mov     WORD old10 + 2, es              ;save segment
  295.  
  296.         mov     ax, 3516H                       ;get interrupt 16H function
  297.         int     21H                             ;execute
  298.         mov     WORD old16, bx                  ;save offset
  299.         mov     WORD old16 + 2, es              ;save segment
  300.  
  301.         mov     ah, 49H                         ;release memory
  302.         mov     es, [2CH]                       ;environment segment
  303.         int     21H                             ;execute
  304.         pop     es
  305.  
  306.         mov     si, OFFSET BEGIN_RESIDENT       ;start of resident code
  307.         mov     di, NEWLOC                      ;new location
  308.         mov     cx, OFFSET END_RESIDENT         ;end
  309.         sub     cx, si                          ;bytes of code
  310.         cld
  311.         rep
  312.         movsb                                   ;copy code
  313.  
  314.         mov     ax, 2510H                       ;set interrupt 10H function
  315.         mov     dx, OFFSET New10 - RELOC        ;offset, segement in DS
  316.         int     21H                             ;execute
  317.  
  318.         mov     ax, 2516H                       ;set interrupt 16H function
  319.         mov     dx, OFFSET New16 - RELOC        ;offset, segement in DS
  320.         int     21H                             ;execute
  321.  
  322.         mov     ax, OFFSET END_RESIDENT - RELOC ;end of resident code
  323.         mov     cl, 4                           ;bits to shift
  324.         mov     dx, ax
  325.         shr     dx, cl                          ;convert to paragraph
  326.         and     ax, 0FH                         ;mask remainder
  327.         sub     ah, al                          ;set carry if non-zero
  328.         adc     dx, 0                           ;update paragraphs
  329.  
  330.         mov     ax, 3100H                       ;TSR
  331.         int     21H                             ;execute
  332.  
  333. ;--- terminate
  334.  
  335. term    mov     ax, cx
  336.         call    MesPutL                 ;display message
  337.  
  338.         mov     ax, 4CFFH               ;error terminate
  339.         int     21H                     ;execute
  340.  
  341. ;--- data
  342.  
  343. banner  DB      13,10,'Scroll  Version 1.00  By Eric Tauck',0
  344. status  DB      'Installed with scroll = ',0
  345. error   DB      'Error in parameters, run SCROLL ? for help',0
  346. help    DB      'Usage: SCROLL [lines]  default = 24',0
  347.  
  348. buffer  LABEL   BYTE
  349.         ORG     +6
  350.